home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Alien Robot/ w alien inside
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "m_mambass.h"
-
-
- static int sound_pain;
- static int sound_die;
- static int sound_idle;
- static int sound_punch;
- static int sound_sight;
- static int sound_search;
-
- void ambass_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- }
-
- void ambass_search (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
- }
-
-
- void ambass_fidget (edict_t *self);
- mframe_t ambass_frames_stand [] =
- {
- ai_stand, 0, ambass_fidget,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t ambass_move_stand = {FRAME_attack01, FRAME_attack01, ambass_frames_stand, NULL};
-
- void stomp_right (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- right[0] = right[0] * 15;
- right[1] = right[1] * 15;
- forward[0] = forward[0] * 10;
- forward[1] = forward[1] * 10;
-
- VectorAdd(start, forward, start);
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
-
- }
- void stomp_left (edict_t *self)
- {
- int i;
- edict_t *e;
- vec3_t forward, right;
- vec3_t start;
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 50;
- e->velocity[1] += crandom()* 50;
- e->velocity[2] += crandom()* 100;
- }
-
- AngleVectors (self->s.angles, forward, right, NULL);
- VectorCopy (self->s.origin, start);
-
- //start[2] = start[2] - 16;
-
- right[0] = right[0] * -10;
- right[1] = right[1] * -10;
-
- forward[0] = forward[0] * 15;
- forward[1] = forward[1] * 15;
-
- VectorAdd(start, forward, start);
-
- VectorAdd(start, right, start);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION2);
- gi.WritePosition (start);
- gi.multicast (start, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
-
- }
-
- void fall (edict_t *self)
- {
- int i;
-
- edict_t *e;
-
-
- for (i=1, e=g_edicts+i; i < globals.num_edicts; i++,e++)
- {
- if (!e->inuse)
- continue;
- if (!e->client)
- continue;
- if (!e->groundentity)
- continue;
-
- e->groundentity = NULL;
- e->velocity[0] += crandom()* 250;
- e->velocity[1] += crandom()* 250;
- e->velocity[2] += crandom()* 500;
- }
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
-
- }
-
- void ambass_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &ambass_move_stand;
- }
-
- mframe_t ambass_frames_stand_fidget [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
- mmove_t ambass_move_stand_fidget = {FRAME_attack01, FRAME_attack01, ambass_frames_stand_fidget, ambass_stand};
-
- void ambass_fidget (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- return;
- if (random() > 0.15)
- return;
-
- self->monsterinfo.currentmove = &ambass_move_stand_fidget;
- gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
- }
-
- //----leader stuff
-
-
- void mleader_fidget (edict_t *self);
- mframe_t mleader_frames_stand [] =
- {
- ai_stand, 0, mleader_fidget,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t mleader_move_stand = {FRAME_stand01, FRAME_stand06, mleader_frames_stand, NULL};
-
- void mleader_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &mleader_move_stand;
- }
-
- mframe_t mleader_frames_stand_fidget [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
- mmove_t mleader_move_stand_fidget = {FRAME_fidget01, FRAME_fidget11, mleader_frames_stand_fidget, mleader_stand};
-
- void mleader_fidget (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- return;
- if (random() > 0.15)
- return;
-
- self->monsterinfo.currentmove = &mleader_move_stand_fidget;
- gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
- }
-
-
-
- mframe_t ambass_frames_walk [] =
- {
- ai_walk, 3.1, NULL,
- ai_walk, 4.3, NULL,
- ai_walk, 4.9, NULL,
- ai_walk, 2.7, NULL,
- ai_walk, 3.0, NULL,
- ai_walk, 3.2, NULL,
- ai_walk, 4.9, NULL,
- ai_walk, 2.7, NULL,
- ai_walk, 3.0, NULL,
- ai_walk, 3.2, NULL,
- ai_walk, 4.2, NULL,
- ai_walk, 3.1, NULL
- };
- mmove_t ambass_move_walk = {FRAME_run01, FRAME_run12, ambass_frames_walk, NULL};
-
- void ambass_walk (edict_t *self)
- {
- self->monsterinfo.currentmove = &ambass_move_walk;
- gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_NORM, 0);
- }
-
- mframe_t ambass_frames_run1 [] =
- {
- ai_run, 10, NULL,
- ai_run, 15, NULL,
- ai_run, 20, NULL,
- ai_run, 15, NULL,
- ai_run, 0, stomp_right,
- ai_run, 6, NULL,
- ai_run, 11, NULL,
- ai_run, 15, NULL,
- ai_run, 20, NULL,
- ai_run, 16, NULL,
- ai_run, 0, stomp_left,
- ai_run, 5, NULL
- };
- mmove_t ambass_move_run1 = {FRAME_run01, FRAME_run12, ambass_frames_run1, NULL};
-
- void ambass_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &ambass_move_stand;
- else
- self->monsterinfo.currentmove = &ambass_move_run1;
- gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_NORM, 0);
- }
-
-
- void ambass_attack_spike (edict_t *self)
- {
- static vec3_t aim = {MELEE_DISTANCE, 0, -24};
- gi.sound (self, CHAN_WEAPON, sound_search, 1, ATTN_NORM, 0);
- fire_hit (self, aim, (15 + (rand() % 6)), 100); // Faster attack -- upwards and backwards
- }
-
-
- void ambass_swing (edict_t *self)
- {
- gi.sound (self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0);
- }
-
- void ambassShot (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t dir;
- vec3_t vec;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_JORG_BFG_1], forward, right, start);
-
- VectorCopy (self->enemy->s.origin, vec);
- vec[2] += self->enemy->viewheight;
- VectorSubtract (vec, self->s.origin, dir);
- VectorNormalize (dir);
- //gi.sound (self, CHAN_VOICE, sound_attack2, 1, ATTN_NORM, 0);
- /*void monster_fire_bfg (edict_t *self,
- vec3_t start,
- vec3_t aimdir,
- int damage,
- int speed,
- int kick,
- float damage_radius,
- int flashtype)*/
- gi.sound (self, CHAN_VOICE, sound_punch, 1, ATTN_NORM, 0);
- monster_fire_bfg (self, self->s.origin, dir, 50, 300, 100, 200, MZ2_JORG_BFG_1);
- }
-
- void ambass_strike (edict_t *self)
- {
- static vec3_t aim = {MELEE_DISTANCE, 0, -24};
- gi.sound (self, CHAN_WEAPON, sound_search, 1, ATTN_NORM, 0);
- fire_hit (self, aim, (75 + (rand() % 6)), 100); // Faster attack -- upwards and backwards
- }
-
- mframe_t ambass_frames_attack_spike [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambass_strike,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t ambass_move_attack_spike = {FRAME_attack01, FRAME_attack07, ambass_frames_attack_spike, ambass_run};
-
-
- void ambass_attack_club (edict_t *self)
- {
- vec3_t aim;
-
- VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
- fire_hit (self, aim, (5 + (rand() % 6)), 400); // Slower attack
- }
-
- mframe_t ambass_frames_attack_club [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambass_strike,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t ambass_move_attack_club = {FRAME_attack01, FRAME_attack07, ambass_frames_attack_club, ambass_run};
-
-
-
-
- mframe_t ambass_frames_attack_strike [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambass_strike,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
-
- mmove_t ambass_move_attack_strike = {FRAME_attack01, FRAME_attack07, ambass_frames_attack_strike, ambass_run};
-
-
- void ambass_melee (edict_t *self)
- {
- if ((rand() % 2) == 0)
- self->monsterinfo.currentmove = &ambass_move_attack_spike;
- else
- self->monsterinfo.currentmove = &ambass_move_attack_club;
- }
-
- mframe_t mleader_frames_attack_spike [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambassShot,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t mleader_move_attack_spike = {FRAME_attack01, FRAME_attack07, mleader_frames_attack_spike, ambass_run};
-
-
- void mleader_attack_club (edict_t *self)
- {
- vec3_t aim;
-
- VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
- fire_hit (self, aim, (5 + (rand() % 6)), 400); // Slower attack
- }
-
- mframe_t mleader_frames_attack_club [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambassShot,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t mleader_move_attack_club = {FRAME_attack01, FRAME_attack07, mleader_frames_attack_club, ambass_run};
-
-
-
-
- mframe_t mleader_frames_attack_strike [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, ambassShot,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
-
- mmove_t mleader_move_attack_strike = {FRAME_attack01, FRAME_attack07, mleader_frames_attack_strike, ambass_run};
-
-
- void mleader_melee (edict_t *self)
- {
- if ((rand() % 2) == 0)
- self->monsterinfo.currentmove = &mleader_move_attack_spike;
- else
- self->monsterinfo.currentmove = &mleader_move_attack_club;
- }
- /*
- void() ambass_atke1 =[ $r_attb1, ambass_atke2 ] {ai_run(9);};
- void() ambass_atke2 =[ $r_attb2, ambass_atke3 ] {ai_run(6);};
- void() ambass_atke3 =[ $r_attb3, ambass_atke4 ] {ai_run(18.4);};
- void() ambass_atke4 =[ $r_attb4, ambass_atke5 ] {ai_run(25);};
- void() ambass_atke5 =[ $r_attb5, ambass_atke6 ] {ai_run(14);};
- void() ambass_atke6 =[ $r_attb6, ambass_atke7 ] {ai_run(20);};
- void() ambass_atke7 =[ $r_attb7, ambass_atke8 ] {ai_run(8.5);};
- void() ambass_atke8 =[ $r_attb8, ambass_atke9 ] {ai_run(3);};
- void() ambass_atke9 =[ $r_attb9, ambass_atke10 ] {ai_run(17.5);};
- void() ambass_atke10 =[ $r_attb10, ambass_atke11 ] {ai_run(17);};
- void() ambass_atke11 =[ $r_attb11, ambass_atke12 ] {ai_run(9);};
- void() ambass_atke12 =[ $r_attb12, ambass_atke13 ] {ai_run(25);};
- void() ambass_atke13 =[ $r_attb13, ambass_atke14 ] {ai_run(3.7);};
- void() ambass_atke14 =[ $r_attb14, ambass_atke15 ] {ai_run(2.6);};
- void() ambass_atke15 =[ $r_attb15, ambass_atke16 ] {ai_run(19);};
- void() ambass_atke16 =[ $r_attb16, ambass_atke17 ] {ai_run(25);};
- void() ambass_atke17 =[ $r_attb17, ambass_atke18 ] {ai_run(19.6);};
- void() ambass_atke18 =[ $r_attb18, ambass_run1 ] {ai_run(7.8);};
- */
-
-
- mframe_t ambass_frames_pain1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t ambass_move_pain1 = {FRAME_run01, FRAME_run08, ambass_frames_pain1, ambass_run};
-
-
- mframe_t ambass_frames_pain2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t ambass_move_pain2 = {FRAME_run01, FRAME_run08, ambass_frames_pain2, ambass_run};
-
- void ambass_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- vec3_t end;
-
- if (level.time < self->pain_debounce_time)
- return;
-
- self->pain_debounce_time = level.time + 3;
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
-
- if(self->health < 300)
- {
- VectorCopy(self->s.origin, end);
- end[2] += 64;
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (end);
- gi.multicast (end, MULTICAST_PVS);
- self->s.skinnum = 1;
- self->s.effects |= EF_ROCKET;//make him damaged and smoking
- }
-
- if ((damage < 20) || (random() < 0.5))
- self->monsterinfo.currentmove = &ambass_move_pain1;
- else
- self->monsterinfo.currentmove = &ambass_move_pain2;
- }
-
- void ambass_dead (edict_t *self)
- {
- VectorSet (self->mins, -32, -32, 0);
- VectorSet (self->maxs, 32, 32, 48);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
-
- }
-
- mframe_t ambass_frames_death1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, fall
-
- };
- mmove_t ambass_move_death1 = {FRAME_stand01, FRAME_fidget01, ambass_frames_death1, ambass_dead};
-
- mframe_t ambass_frames_death2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, fall
- };
- mmove_t ambass_move_death2 = {FRAME_stand01, FRAME_fidget01, ambass_frames_death2, ambass_dead};
-
-
- void ambass_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- vec3_t end;
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
-
- self->takedamage = DAMAGE_NO;
- VectorCopy(self->s.origin, end);
- end[2] += 64;
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (end);
- gi.multicast (end, MULTICAST_PVS);
-
- ThrowDebris (self, "models/objects/gibs/robot_leg/tris.md2", 0, end);
- self->s.modelindex = gi.modelindex("models/monsters/martian_robot/tris2.md2");
- self->s.skinnum = 1;
-
- self->deadflag = DEAD_DEAD;
-
-
- if (damage >= 50)
- self->monsterinfo.currentmove = &ambass_move_death1;
- else
- self->monsterinfo.currentmove = &ambass_move_death2;
- }
-
- /*QUAKED monster_ambass (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_monster_ambass (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("martian/robotmove.wav");
-
-
- sound_punch = gi.soundindex ("martian/shoot1.wav");
- sound_search = gi.soundindex ("robot9/mach2.wav");
- sound_sight = gi.soundindex ("martian/robotmov.wav");
-
- sound_idle = gi.soundindex ("robot9/mach.wav");
- sound_die = gi.soundindex ("martian/step.wav");
-
- self->s.modelindex = gi.modelindex("models/monsters/martian_robot/tris.md2");
- self->s.modelindex2 = gi.modelindex("models/monsters/robot_top/tris.md2");
- self->s.modelindex3 = gi.modelindex("models/monsters/robot_head/tris.md2");
-
- VectorSet (self->mins, -32, -32, 0);
- VectorSet (self->maxs, 32, 32, 156);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
- self->s.skinnum = 0;
-
- self->max_health = 600;
- self->health = self->max_health;
- self->gib_health = 0;
- self->mass = 450;
-
- self->classname = "monster_ambass";
-
- self->pain = ambass_pain;
- self->die = ambass_die;
-
- self->monsterinfo.stand = ambass_stand;
- self->monsterinfo.walk = ambass_walk;
- self->monsterinfo.run = ambass_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = ambass_melee;
- self->monsterinfo.sight = ambass_sight;
- self->monsterinfo.search = ambass_search;
-
- self->monsterinfo.currentmove = &ambass_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
-
- }
-